{% load ts_extras %}
<div id="ts_list" class="treeview">
    <div class="treeview-header">
        <h2>SimGenex program list</h2>
    </div>
    <div class="treeview-body">
        {% if request.session.sgx_programs %}
        <ul class="list-lv1">
            {% for sgxp in request.session.sgx_programs %}
            <li {% if sgxp.name == request.session.sgx_program.name %}
                class="active"
                {% endif %}
                >
                <div class="collapsed treeview-header">
                    <a class="expand" href="#" title="expand" ></a>
                    <a class="collap" href="#" title="collap" ></a>
                    <h3><a title="SimGenex program {{sgxp.name}}" href="{% url tsworkbench.views.sgx.viewSgx sgxp.name|escapeUrl %}">{{sgxp.name}}</a></h3>
                    <a id="{% url tsworkbench.views.sgx.delSgx sgxp.name|escapeUrl %}" rev="simgenex program" class="delete" href="#" title="delete" ></a>
                </div>
                <div class="expanded">
                    <!-- Target transsys program List -->
                    <div class="treeview-lv1">
                        <div class="collapsed treeview-header">
                            <h4>Target transsys program list</h4>
                            <a class="expand" href="#" title="expand" ></a>
                            <a class="collap" href="#" title="collap" ></a>
                        </div>
                        <div class="expanded">
                            {% if sgxp.target_tp %}
                            <ul {% if tp.name == request.session.ts_program.tp.name %}
                                    class="list-lv1"
                                {% else %}
                                    class="list-lv2"
                                {% endif %}
                                >
                                {% for tp in sgxp.target_tp %}
                                    {% include "simgenex/targetTpListing.html" %}
                                {% endfor%}
                            </ul>
                            {%else%}
                            <p>No target tp</p>
                            {%endif%}
                        </div>
                    </div>
                    <!-- Procedures List -->
                    <div class="treeview-lv1">
                        <div class="collapsed treeview-header">
                            <h4>Procedure list</h4>
                            <a class="expand" href="#" title="expand" ></a>
                            <a class="collap" href="#" title="collap" ></a>
                        </div>
                        <div class="expanded">
                            {% if sgxp.sgx.procedure_defs %}
                            

                            <ul class="list-lv2">
                                {% for p in sgxp.sgx.procedure_defs %}
                                <li>
                                    <div class="collapsed">
                                        <a title="procedure {{p.procedure_name}}" href="{% url tsworkbench.views.sgx.editProcedure sgxp.name|escapeUrl p.procedure_name %}" >{{p.procedure_name}}</a>
                                        <a class="expand" href="#" title="expand" ></a>
                                        <a class="collap" href="#" title="collap" ></a>
                                        <a id="{% url tsworkbench.views.sgx.delProcedure sgxp.name|escapeUrl p.procedure_name%}" rev="procedure" class="delete" href="#" title="delete" ></a>
                                    </div>
                                    <div class="expanded">
                                        {% for instruction in p.instruction_list %}
                                        <ul>
                                            <li>{{instruction}}</li>
                                        </ul>
                                        {% endfor %}
                                    </div>
                                </li>
                                {% endfor%}
                            </ul>
                            {%else%}
                            <p>No procedures</p>
                            {%endif%}
                        </div>
                    </div>

                    <!-- SimExpression List -->
                    <div class="treeview-lv1">
                        <div class="collapsed treeview-header">
                            <h4>Simulating Gene Expression list</h4>
                            <a class="expand" href="#" title="expand" ></a>
                            <a class="collap" href="#" title="collap" ></a>
                        </div>
                        <div class="expanded">
                            {% if sgxp.sgx.simexpression_defs %}

                            <ul class="list-lv2">
                                {% for p in sgxp.sgx.simexpression_defs %}
                                <li>
                                    <div class="collapsed">
                                        <a title="procedure {{p.simexpression_name}}" href="{% url tsworkbench.views.sgx.editSimexpression sgxp.name|escapeUrl p.simexpression_name %}" >{{p.simexpression_name}}</a>
                                        <a class="expand" href="#" title="expand" ></a>
                                        <a class="collap" href="#" title="collap" ></a>
                                        <a id="{% url tsworkbench.views.sgx.delSimexpression sgxp.name|escapeUrl p.simexpression_name %}" rev="simexpression" class="delete" href="#" title="delete" ></a>
                                    </div>
                                    <div class="expanded">
                                        {% for instruction in p.instruction_list %}
                                        <ul>
                                            <li>{{instruction}}</li>
                                        </ul>
                                        {% endfor %}
                                    </div>
                                </li>
                                {% endfor%}
                            </ul>
                            {%else%}
                            <p>No Simulation Gene Expression</p>
                            {%endif%}
                        </div>
                    </div>

                    <!-- Measurement Matrix -->
                    <div class="treeview-lv1">
                        <div class="collapsed treeview-header">
                            <h4>Measurement Matrix</h4>
                            <a class="expand" href="#" title="expand" ></a>
                            <a class="collap" href="#" title="collap" ></a>
                        </div>
                        <div class="expanded">
                            {% if sgxp.sgx.measurementmatrix_def %}

                            <ul class="list-lv2">
                                <li>
                                    <div class="collapsed">
                                        <a title="Edit measurement matrix settings" href="{% url tsworkbench.views.sgx.addMeasurementMatrix sgxp.name|escapeUrl %}" >Measurement Process</a>
                                        <a class="expand" href="#" title="expand" ></a>
                                        <a class="collap" href="#" title="collap" ></a>
                                    </div>
                                    <div class="expanded">
                                        <ul>
                                            <li>{{sgxp.sgx.measurementmatrix_def.measurementprocess}}</li>
                                        </ul>
                                    </div>
                                </li>
                                <li>
                                    <div class="collapsed">
                                        <a title="Edit measurement matrix settings" href="{% url tsworkbench.views.sgx.addMeasurementMatrix sgxp.name|escapeUrl %}" >Measurement Column List</a>
                                        <a class="expand" href="#" title="expand" ></a>
                                        <a class="collap" href="#" title="collap" ></a>
                                    </div>
                                    <div class="expanded">
                                        <ul>
                                            {% for col in sgxp.sgx.measurementmatrix_def.measurementcolumn_list %}
                                            <li>{{col}}</li>
                                            {% endfor %}
                                        </ul>
                                    </div>
                                </li>
                                <li>
                                    <div class="collapsed">
                                        <a title="Edit measurement matrix settings" href="{% url tsworkbench.views.sgx.addMeasurementMatrix sgxp.name|escapeUrl %}" >Gene mapping</a>
                                        <a class="expand" href="#" title="expand" ></a>
                                        <a class="collap" href="#" title="collap" ></a>
                                    </div>
                                    <div class="expanded">
                                        <ul>
                                            {% for k,v in sgxp.sgx.measurementmatrix_def.genemapping.factor_dict.items %}
                                            <li>{{k}}:{{v}}</li>
                                            {% endfor %}
                                        </ul>
                                    </div>
                                </li>
                            </ul>
                            {%else%}
                            <p>No measurement matrix settings</p>
                            {%endif%}
                        </div>
                    </div>
                    <!-- Discrimination Settings -->
                    <div class="treeview-lv1">
                        <div class="collapsed treeview-header">
                            <h4>Discrimination Settings</h4>
                            <a class="expand" href="#" title="expand" ></a>
                            <a class="collap" href="#" title="collap" ></a>
                        </div>
                        <div class="expanded">
                            {% if sgxp.sgx.discriminationsettings_def %}

                            <ul class="list-lv2">
                                <li>
                                    <div class="collapsed">
                                        <a title="Edit discrimination settings" href="{% url tsworkbench.views.sgx.discriminationSetting sgxp.name|escapeUrl %}" >Distance</a>
                                        <a class="expand" href="#" title="expand" ></a>
                                        <a class="collap" href="#" title="collap" ></a>
                                    </div>
                                    <div class="expanded">
                                        <ul>
                                            <li>{{sgxp.sgx.discriminationsettings_def.get_distance}}</li>
                                        </ul>
                                    </div>
                                </li>
                                <li>
                                    <div class="collapsed">
                                        <a title="Edit discrimination settings" href="{% url tsworkbench.views.sgx.discriminationSetting sgxp.name|escapeUrl %}" >White List</a>
                                        <a class="expand" href="#" title="expand" ></a>
                                        <a class="collap" href="#" title="collap" ></a>
                                    </div>
                                    <div class="expanded">
                                        <h5>Factor</h5>
                                        <ul>
                                            {% for factor in sgxp.sgx.discriminationsettings_def.get_whitelist.factor_list %}
                                            <li>{{factor}}</li>
                                            {% endfor %}
                                        </ul>
                                        <h5>Gene</h5>
                                        <ul>
                                            {% for gene in sgxp.sgx.discriminationsettings_def.get_whitelist.gene_list %}
                                            <li>{{gene}}</li>
                                            {% endfor %}
                                        </ul>
                                    </div>
                                </li>
                            </ul>
                            {%else%}
                            <p>No discrimination settings</p>
                            {%endif%}
                        </div>
                    </div>
                    <!-- Target expression data set List -->
                    <div class="treeview-lv1">
                        <div class="collapsed treeview-header">
                            <h4>Target expression data list</h4>
                            <a class="expand" href="#" title="expand" ></a>
                            <a class="collap" href="#" title="collap" ></a>
                        </div>
                        <div class="expanded">
                            {% if sgxp.target_expression_data %}
                            <ul class="list-lv2">
                                {% for ex_name in sgxp.target_expression_data.keys %}
                                
                                <li >
                                    <div class="collapsed">
                                    <a title="transsys program {{ex_name}}" href="{% url tsworkbench.views.sgx.viewExpressionSet sgxp.name|escapeUrl ex_name %}?next={{request.path}}" >{{ex_name}}</a>
                                    <a id="{% url tsworkbench.views.sgx.delExpressionSet sgxp.name|escapeUrl ex_name %}" rev="dataset" class="delete" href="#" title="delete" ></a>
                                    </div>
                                </li>
                                
                                {% endfor%}
                            </ul>
                            {%else%}
                            <p>There are no expression dataset. Click upload expression dataset on the right panel for upload one.</p>
                            {%endif%}
                        </div>
                    </div>
                </div>
            </li>
            {% endfor %}
        </ul>
        <div class="treeview-footer">
            <a id="add_new" class="link-button" href="{%url tsworkbench.views.sgx.addSgx %}" title="Add new SimGenex program">Add new</a>
            <a id="upload_new" class="link-button" href="{% url tsworkbench.views.sgx.uploadSgx %}" title="Upload SimGenex code">Upload new</a>
            <a id="export" class="link-button" href="{% url tsworkbench.views.exportWorkspace %}" title="Export workspace">Export</a>
            <a id="import" class="link-button" href="{% url tsworkbench.views.importWorkspace %}" title="Import workspace">Import</a>
        </div>
        {%else%}
        <p>No SimGenex program</p>
        <div class="treeview-footer">
        <a id="add_new" class="link-button" href="{%url tsworkbench.views.sgx.addSgx %}" title="Add new SimGenex program">Add new</a>
        <a id="upload_new" class="link-button" href="{% url tsworkbench.views.sgx.uploadSgx %}" title="Upload SimGenex code">Upload new</a>
        <a id="export" class="link-button" href="{% url tsworkbench.views.exportWorkspace %}" title="Export workspace">Export</a>
            <a id="import" class="link-button" href="{% url tsworkbench.views.importWorkspace %}" title="Import workspace">Import</a>
        </div>
        {%endif%}
    </div>
</div>